<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>商品管理</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="css/add_type.css">
<script type="text/javascript">
	//删除已选中的类型
		function delect(){
			var gys=document.getElementsByName("gysname"); 
			var gysId="";
			for(var i=0;i<gys.length;i++){
				if(gys[i].checked){
					gysId+=gys[i].value;
					gysId+="-";
				}
			}
		
			if(gysId==""){
				alert("没有选中，无法删除");
			}else{
				var c=confirm("确定删除");
				if(c==true){
					window.location.href="delect_gys.do?gysId="+gysId; 
				}
			}
		}
		
		//校验
		function jiaoyan(){
			var type=document.getElementById("add_gysId").value;
		
			if(type==""){
				alert("供应商不能输入空");
				return false;
			}else{
				alert("添加成功");
				return true;
			}
		}
		function losefocus(){
		
			if(document.getElementById("add_gysId").value==""){
				document.getElementById("null_span").innerText="供应商不能为空";
			}
				
		}
	    function getfocus(){
		
			
			document.getElementById("null_span").innerText="";
			
				
		}	
		
	</script>

</head>

<body>
	<!--总div  -->
	<%-- <div class="div_all">

		
					<div style="position: absolute;">
			<!--判断是否登录  -->
			<c:if test="${username1!=null}">
				<span style="color:red;">用户名: ${username1}</span>
			</c:if>
			<c:if test="${username1==null}">
				<a href="dengru.jsp" style="text-decoration: none;color:red;">亲，请登入</a>
			</c:if></div>
		<!-- 	<div class="div_menu">
				<a href="add_goods_showtype.do" class="a_menu">添加商品 </a>
  				<a href="show_goods.do" class="a_menu">查询商品 </a>
  				<a href="add_type.do" class="a_menu">类别管理 </a>
  				<a href="show_ads.do" class="a_menu">广告维护 </a>
  				<a href="zhuce.jsp" class="a_menu">注册账号 </a>
  				<a href="qiehuanUser.do" class="a_menu">切换账号 </a>
  				<a href="select_orders.do" class="a_menu">订单查询 </a>
  				<a href="go_tongji.do" class="a_menu">销售统计 </a>
			</div> -->
		</div> --%>

		<div class="div_2">
			<div class="div_add">
				<form action="add_gys.do" method="post" onsubmit="return jiaoyan()">
					<span class="good">供应商:</span><input type="text" class="add_input"
						name="name" id="add_gysId" onblur="losefocus()"
						onfocus="getfocus()" /> <input type="submit" class="cha_input"
						value="添加" /> <br />
					<span class="jiaoyan" id="null_span"></span>
				</form>
			</div>
		</div>
		
		
		<!--遍历已有商品类型-->
		<%int i=0; %>
		<div class="div_3">
			<div class="div_cha" id="showtypeId">
				<br /> &nbsp;&nbsp;&nbsp;<font color=red;>已有供应商:</font>
				<c:forEach items="${gysList}" var="list">
					<div class="type_div">
						<input type="checkbox" name="gysname" value="${list.id}" />&nbsp;&nbsp;<span>${list.name}</span>
					</div>
					<% i++;;%>
				</c:forEach>

				<input type="button" value="删除" class="delete" onclick="delect()" />
			</div>
		</div>
	</div>


</body>
</html>
